package com.demo.cms.dao.impl;

import java.util.Map;

import com.demo.cms.dao.ChannelDao;
import com.demo.cms.model.Channel;
import com.demo.core.dao.impl.base.PageCoreDaoSupport;
import com.demo.core.model.support.GeneralExecuteModel;

/**
 * 频道数据访问实现类
 * 
 * @author ryuu.kk
 *
 */
public class ChannelDaoImpl extends PageCoreDaoSupport<Channel, Long> implements ChannelDao {

	/**
	 * 目录空间 
	 */
	protected final static String TABLE_SPACE = "channelSpace.";
	/**
	 * 模型表名
	 */
	protected final static String TABLE_NAME = "T_CMS_CHANNEL";
	/**
	 * 模型表主键ID
	 */
	protected final static String TABLE_PK_NAME = "ID";
	
	@Override
	protected String nameSpace() {
		return TABLE_SPACE;
	}

	@Override
	protected void doInit(GeneralExecuteModel<Long> model) {
		model.setPk(TABLE_PK_NAME);
		model.setTable(TABLE_NAME);
	}

	@Override
	public int updateEnabled(Channel channel, Map<String, Object> params) {
		params.put("channel", channel);
		return getSqlMapClientTemplate().update(nameSpace() + "changeEnabled", params);
	}
	@Override
	public int updateStatus(String status, Map<String, Object> params) {
		Channel channel = new Channel();
		channel.setStatus(status);
		params.put("channel", channel);
		return getSqlMapClientTemplate().update(nameSpace() + "changeStatus", params);
	}
}
